
import { ref, unref, watch, onMounted } from 'vue'
import { post } from '../../../api'
import { ElMessageBox, ElMessage } from 'element-plus'

export function init(self) {
  const module = self.module.value
  self.custom = {
    columns : [
      {
        prop: 'id',
        order: 'desc',
        width: 100,
      },
      {
        prop: 'table_name',
        width: 200,
      },
      {
        prop: 'update_time',
      },
      {
        prop: 'content',
        width: 800,
      },
      {
        prop: 'remark',
        hide: true,
      },
    ],

    editColumns : [
      {
        prop: 'table_name',
      },
      {
        prop: 'content',
        type: 'textarea',
        rows: 10,
      },
      {
        prop: 'remark',
        hide: true,
      },
    ],

    queryColumns : [
      {
        prop: 'table_name_like',
        label: '表',
      },
      {
        prop: 'content_like',
        label: '内容',
      },
    ],

    buttons: [
      {
        prop: 'clearHistory',
        label: '清空',
        loading: false,
        onclick: (param) => {
          ElMessageBox.confirm('是否要清空修改历史？此操作不可恢复', '警告', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            closeOnClickModal: false,
            type: 'warning',
          })
            .then(() => {
              post('sdp_history', 'clear', {})
              .then (data => {
                ElMessage.success('操作成功')
                self.handleSearch();
              })
            })
        }
      },
    ],

    remoteConfig : {
    },

  }
}

